package arr

import (
	"strconv"
	"strings"
)

/*
方法一:模拟
时间复杂度：O(N)
空间复杂度：O(1)
*/
func fizzBuzz(n int) []string {
	result := make([]string, 0)
	for i := 1; i <= n; i++ {
		sb := &strings.Builder{}
		if i % 3 ==  0 {
			sb.WriteString("Fizz")
		}
		if i % 5 == 0 {
			sb.WriteString("Buzz")
		}
		if sb.Len() == 0 {
			sb.WriteString(strconv.Itoa(i))
		}
		result = append(result, sb.String())
	}
	return result
}

func fizzBuzz1(n int) []string {
	result := make([]string, 0)
	for i := 1; i <= n; i++ {
		if i % 15 == 0 {
			result = append(result, "FizzBuzz")
		} else if i % 3 == 0 {
			result = append(result, "Fizz")
		} else if i % 5 == 0 {
			result = append(result, "Buzz")
		} else {
			result = append(result, strconv.Itoa(i))
		}
	}
	return result
}